﻿<%@ Page Language="C#" MasterPageFile="../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.Configuration.VWebConfigManagerPage" %>

<script runat="server">
	protected void HttpModulesGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
	{
		HttpModulesDetailsView.ChangeMode(DetailsViewMode.ReadOnly);
	}

	protected void HttpModulesDetailsView_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
	{
		ShowAlert_DetailsView_ItemInserted(e);

		HttpModulesGridView.SelectedIndex = -1;
		HttpModulesGridView.DataBind();
	}

	protected void HttpModulesDetailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
	{
		ShowAlert_DetailsView_ItemUpdated(e);

		HttpModulesGridView.SelectedIndex = -1;
		HttpModulesGridView.DataBind();
	}

	protected void HttpModulesDetailsView_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
	{
		ShowAlert_DetailsView_ItemDeleted(e);

		HttpModulesDetailsView.ChangeMode(DetailsViewMode.Insert);

		HttpModulesGridView.SelectedIndex = -1;
		HttpModulesGridView.DataBind();
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>HttpModules</h2>

	<div>
		<asp:ObjectDataSource ID="HttpModulesDetailsViewDataSource" runat="server" 
			DeleteMethod="RemoveModule" InsertMethod="AddModule" SelectMethod="GetModule" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.HttpModulesSectionManager" 
			UpdateMethod="ModifyModule">
			<DeleteParameters>
				<asp:ControlParameter ControlID="HttpModulesGridView" Name="index" 
					PropertyName="SelectedIndex" Type="Int32" />
			</DeleteParameters>
			<UpdateParameters>
				<asp:ControlParameter ControlID="HttpModulesGridView" Name="index" 
					PropertyName="SelectedIndex" Type="Int32" />
				<asp:Parameter Name="name" Type="String" />
				<asp:Parameter Name="type" Type="String" />
			</UpdateParameters>
			<SelectParameters>
				<asp:ControlParameter ControlID="HttpModulesGridView" Name="index" 
					PropertyName="SelectedIndex" Type="Int32" />
			</SelectParameters>
			<InsertParameters>
				<asp:Parameter Name="name" Type="String" />
				<asp:Parameter Name="type" Type="String" />
			</InsertParameters>
		</asp:ObjectDataSource>
		<asp:ObjectDataSource ID="HttpModulesGridViewDataSource" runat="server" 
			SelectMethod="GetModules" 
			
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.HttpModulesSectionManager"></asp:ObjectDataSource>
		<fieldset>
			<asp:DetailsView ID="HttpModulesDetailsView" runat="server" 
				AutoGenerateRows="False" CellPadding="5" 
				DataSourceID="HttpModulesDetailsViewDataSource" DefaultMode="Insert" 
				oniteminserted="HttpModulesDetailsView_ItemInserted" 
				onitemupdated="HttpModulesDetailsView_ItemUpdated" 
				onitemdeleted="HttpModulesDetailsView_ItemDeleted">
				<Fields>
					<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
					<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
					<asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
						ShowEditButton="True" ShowInsertButton="True" />
				</Fields>
			</asp:DetailsView>
			<asp:GridView ID="HttpModulesGridView" runat="server" 
				AutoGenerateColumns="False" CellPadding="5" 
				DataSourceID="HttpModulesGridViewDataSource" 
				onselectedindexchanging="HttpModulesGridView_SelectedIndexChanging">
				<Columns>
					<asp:CommandField ShowSelectButton="True" />
					<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
					<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
				</Columns>
				<SelectedRowStyle BackColor="SkyBlue" />
			</asp:GridView>
		</fieldset>
	</div>
</asp:Content>